package com.zhiguang.cms.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

import com.zhiguang.cms.entity.User;
import com.zhiguang.cms.utils.CmsContant;


public class CmsInterceptor implements HandlerInterceptor {
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		// TODO Auto-generated method stub
		User loginUser = (User)request.getSession().getAttribute(CmsContant.USER_KEY);
		if(loginUser==null) {
			response.sendRedirect("/user/login");
			return false;
		}
		
		return true;
		
	}

}
